﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace FBGraph.Async
{
    /// <summary>An exception that is thrown when an asynchronous Graph API call fails.</summary>
    public class FBGraphAsyncApiException : Exception
    {
        /// <summary>Initializaes an instance of <see cref="FBGraphAsyncApiException" /> using the specified collection
        /// of <see cref="AsyncContainer.AsyncErrorData" /> objects.</summary>
        /// <param name="errorData">A collection of <see cref="AsyncContainer.AsyncErrorData" /> objects containing information about
        /// errors that occurred during an asynchronous operation.</param>
        public FBGraphAsyncApiException(ICollection<AsyncContainer.AsyncErrorData> errorData)
            : base("One or more asynchronous Graph API calls failed.", errorData.First().Exception)
        {
            this.ErrorData = errorData;
        }

        /// <summary>Gets a collection of <see cref="AsyncContainer.AsyncErrorData" /> objects containing information
        /// about errors that occurred during an asynchronous operation.
        /// </summary>
        public ICollection<AsyncContainer.AsyncErrorData> ErrorData { get; private set; }
    }
}